package com.erp.erp_project.core.exception;

import com.erp.erp_project.core.base.AjaxResult;
import com.erp.erp_project.model.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author yh
 */
@ControllerAdvice
public class HandleExceptionController {
    @ResponseBody
    @ExceptionHandler(CustomException.class)
    public AjaxResult<String> handleCustomException(CustomException exception) {
        return new AjaxResult<>(500, exception.getMessage());
    }
    @ResponseBody
    @ExceptionHandler(CustomerException.class)
    public Result<String> handleCustomerException(CustomerException exception) {
        return new Result<>(500, exception.getMessage());
    }

    @ResponseBody
    @ExceptionHandler(CheckException.class)
    public String handleCheckException(CheckException exception) {
        return exception.getMessage();
    }
}
